package com.rongshu.view.userInfo.presenter;

import android.content.Context;

import com.rongshu.api.RetorfitService;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.userInfo.entity.OrderInfo;
import com.rongshu.view.userInfo.entity.PaySetMeal;
import com.rongshu.view.userInfo.iview.PayView;

import rx.Subscriber;

public class PayPresenter extends BasePresenter<PayView> {

    public PayPresenter(Context context) {
        super(context);
    }

    /**
     * 获取榕树叶充值套餐列表
     */
    public void getRongShuLeaf(int rnd, String sign) {
        RetorfitService.getRongShuLeaf(rnd, sign)
                .subscribe(new Subscriber<PaySetMeal>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(PaySetMeal paySetMeal) {
                        if (getView() != null) {
                            getView().onRongShuLeaf(paySetMeal);
                        }
                    }
                });
    }

    /**
     * 点击充值生成订单
     */
    public void getTopUp(int user_id, int pay_device, int pay_way, int money, int LeafNumber, String sign) {
        RetorfitService.getTopUp(user_id, pay_device, pay_way, money, LeafNumber, sign)
                .subscribe(new Subscriber<OrderInfo>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(OrderInfo orderInfo) {
                        if (getView() != null) {
                            getView().onOrderInfo(orderInfo);
                        }
                    }
                });
    }
}
